package com.atguigu.upp.service;

import com.atguigu.upp.bean.TagInfo;
import com.atguigu.upp.bean.TaskInfo;
import com.atguigu.upp.bean.TaskTagRule;
import com.atguigu.upp.mapper.CKMapper;
import com.atguigu.upp.mapper.TagInfoMapper;
import com.atguigu.upp.mapper.TaskInfoMapper;
import com.atguigu.upp.mapper.TaskTagRuleMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * Created by Smexy on 2022/11/30
 */
public class CKDBService
{
    private CKMapper ckMapper;

    public CKDBService(SqlSession session){
        this.ckMapper = session.getMapper(CKMapper.class);

    }

    public void dropWideTable(String name){

        //isBlank(str): 如果str是null或白字符(‘’，‘  ’，‘ 回车 ’,' tab ')
        if (StringUtils.isBlank(name)){
            throw  new RuntimeException("表名非法!");
        }

        ckMapper.dropTable(name);

    }

    public void createWideTable(String name,String column){

        if (StringUtils.isBlank(name) || StringUtils.isBlank(column)){
            throw  new RuntimeException("表名非法!");
        }

        ckMapper.createWideTable(name,column);
    }

    public void insertBitmap(String tableName,String doDate,String tagSql,String sourceTable){

        if (StringUtils.isBlank(tableName) || StringUtils.isBlank(doDate)
            || StringUtils.isBlank(tableName) || StringUtils.isBlank(doDate)){
            throw  new RuntimeException("参数非法!");
        }

        ckMapper.insertBitmap(tableName,doDate,sourceTable,tagSql);

    }

    public void cleanHistoryBitmap(String table,String doDate){
        if (StringUtils.isBlank(table) || StringUtils.isBlank(doDate)){
            throw  new RuntimeException("表名非法!");
        }
        ckMapper.cleanHistoryBitmap(table,doDate);
    }



}
